package homework0713;

import puke.Card;
import puke.Doudizhu;

import javax.swing.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class PlayRich extends JFrame {

    private List list = new ArrayList();
    List player1 = new ArrayList();
    List player2 = new ArrayList();
    List player3 = new ArrayList();
    List base = new ArrayList();

    //初始化54张扑克牌
    public void init() {
        String[] types = "1,2,3,4".split(",");
        String[] points = "3,4,5,6,7,8,9,10,J,Q,K,A,2".split(",");
        String[] qianzhui = "3,4,5,6,7,8,9,10,11,12,13,14,15".split(",");

        for (int i = 0; i < types.length; i++) {
            for (int j = 0; j < points.length; j++) {
                list.add(new CardPic(types[i], points[j], j, i, qianzhui[j], types[i]));
            }
        }
        list.add(new CardPic("WANG", "(●￣(ｴ)￣●)", 15, 0, "17", "1"));
        list.add(new CardPic("wang", "(●￣(ｴ)￣●)", 14, 0, "16", "1"));


    }

    //洗牌
    public void xipai() {
        Collections.shuffle(list);
    }

    //发牌
    public void send() {
        player1 = list.subList(0, 17);
        player2 = list.subList(17, 34);
        player3 = list.subList(34, 51);
    }


    public void sort(List list) {
        list.sort(new Comparator<CardPic>() {
            @Override
            public int compare(CardPic o1, CardPic o2) {
                if (o1.getPointValue() == o2.getPointValue()) {
                    return o1.getTypeValue() - o2.getTypeValue();
                } else {
                    return o1.getPointValue() - o2.getPointValue();
                }
            }
        });
    }



}
